home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 45 / Amiga Format CD45 (1999-09)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-11].iso / -coverdisks- / 129a / amimirror / developer / commodity / source / amimirror.h < prev   
C/C++ Source or Header  |  1999-08-17  |  9KB  |  336 lines

  1.  
  2. ///                              ­¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¯                         <
  3. ///
  4. ///”””””””””””””””””””””””””””””ƒ   More includes  ”””””””””””””””””””””””” <
  5. ///
  6. ///                              ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡´                         <
  7. ///
  8.  
  9. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  10. ///
  11. ///                              exec.library                                 <
  12. ///
  13. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  14. ///
  15. #include <clib/exec_protos.h>
  16. #include <pragmas/exec_sysbase_pragmas.h>
  17. #include <exec/types.h>
  18. #include <exec/ports.h>
  19. #include <exec/nodes.h>
  20. #include <exec/alerts.h>
  21. #include <exec/memory.h>
  22. #include <exec/execbase.h>
  23.  
  24. IMPORT struct ExecBase *SysBase;  // Always opened
  25. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  26. ///
  27. ///                       Files management - dos.library                      <
  28. ///
  29. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  30. ///
  31. #include <clib/dos_protos.h>
  32. #include <pragmas/dos_pragmas.h>
  33. #include <dos.h>
  34. #include <dos/dostags.h>
  35.  
  36. IMPORT struct Library *DOSBase;   // Opened with SASC compiler link code
  37. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  38. ///
  39. ///                            intuition.library                              <
  40. ///
  41. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  42. ///
  43. #include <clib/intuition_protos.h>
  44. #include <pragmas/intuition_pragmas.h>
  45.  
  46. #define INTUITION_LIBRARY_NAME      "intuition.library"
  47. #define INTUITION_LIBRARY_VERSION   36L
  48.  
  49. STATIC struct Library *IntuitionBase = NULL;
  50. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  51. ///
  52. ///                             icon.library                                  <
  53. ///
  54. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  55. ///
  56. #include <proto/icon.h>           // Opened with SASC compiler link code
  57. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  58. ///
  59. ///                          commodities.library                              <
  60. ///
  61. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  62. ///
  63. #include <proto/commodities.h>    // Opened with SASC compiler link code
  64. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  65. ///
  66. ///                            xpkmaster.library                              <
  67. ///
  68. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  69. ///
  70. #include <pragma/xpkmaster_lib.h>
  71.  
  72. #define XPK_LIBRARY_NAME    "xpkmaster.library"
  73. #define XPK_LIBRARY_VERSION 4L
  74.  
  75. STATIC struct Library *XpkBase = NULL;
  76. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  77. ///
  78. ///                   Localization support - locale.library                   <
  79. ///
  80. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  81. ///
  82. #include <libraries/locale.h>
  83. #include <clib/locale_protos.h>
  84. #include <pragmas/locale_pragmas.h>
  85.  
  86. #define LOCALE_LIBRARY_NAME         "locale.library"
  87. #define LOCALE_LIBRARY_VERSION      38L
  88. #define CATALOG_LAST_VERSION        2
  89.  
  90. STATIC struct Library *LocaleBase = NULL;
  91. STATIC struct Catalog *catalog    = NULL;
  92. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  93. ///
  94. ///                             and some other...                             <
  95. ///
  96. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  97. ///
  98. #include <error.h>
  99. #include <string.h>
  100. #include <clib/alib_protos.h>
  101. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  102. ///
  103. // Tags of used structures:
  104.  
  105. // header of settings file
  106. struct SetsHeader
  107. {
  108.   ULONG sh_ID;
  109.   ULONG sh_version;
  110.   ULONG sh_amount;
  111. };
  112.  
  113. // header of pattern is settings file
  114. struct PatternHeader
  115. {
  116.   unsigned ph_PatternMode   : 2;
  117.   unsigned ph_StorageMode   : 2;
  118.   unsigned ph_StorageMethod : 2;
  119.   unsigned ph_PerformCheck  : 1;
  120.   unsigned ph_UseXPK        : 1;
  121.   unsigned ph_Function      : 2;
  122.   unsigned ph_pad           : 6;
  123.   UBYTE    ph_XPKName[6];
  124.   UWORD    ph_XPKMode;
  125.   UWORD    ph_PatternSize;
  126.   UWORD    ph_StorageSize;
  127.   UWORD    ph_PasswordSize;
  128. };
  129.  
  130. // work pattern's node
  131. struct PatternNode
  132. {
  133.   struct Node pn_Node;
  134.   unsigned pn_PatternMode   : 2;
  135.   unsigned pn_StorageMode   : 2;
  136.   unsigned pn_StorageMethod : 2;
  137.   unsigned pn_PerformCheck  : 1;
  138.   unsigned pn_UseXPK        : 1;
  139.   unsigned pn_Function      : 2;
  140.   unsigned pn_pad           : 6;
  141.   UBYTE    pn_XPKName[6];
  142.   UWORD    pn_XPKMode;
  143.   UBYTE    pn_Pattern[FMSIZE];
  144.   UBYTE    pn_Storage[FMSIZE];
  145.   UBYTE    pn_Password[32];
  146.   UBYTE    pn_Match[2*FMSIZE+8];
  147. };
  148.  
  149. // all work buffers for any patched function
  150. struct WorkBuf
  151. {
  152.   STRPTR wb_inbuf;
  153.   LONG   wb_inlen;
  154.   UBYTE  wb_path[FMSIZE];
  155.   UBYTE  wb_name[FMSIZE];
  156.   UBYTE  wb_dir[FMSIZE];
  157.   UBYTE  wb_spath[FMSIZE];
  158.   UBYTE  wb_sdir[FMSIZE];
  159.   UBYTE  wb_fault[2*FAULT_MAX];
  160. };
  161.  
  162. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  163. ///
  164. // Some macros:
  165.  
  166. #define REG(x)           register __ ## x
  167. #define GETMES(x)        (messages[x])
  168. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  169.  
  170. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  171. ///
  172. // Some other defines:
  173.  
  174. #define SETS_VERSION                   2L
  175. #define SETS_ID                        MAKE_ID('A','M','I','R')
  176.  
  177. #define ALL_RIGHT                      TRUE           // ;-)
  178. #define GAME_OVER                      FALSE          // :-(
  179.  
  180. #define TASK_PREFS_NAME                "AMIMIRRORPREFS"
  181. #define COM_PORT_NAME                  "AMIMIRROR_PORT"
  182. #define PREFS_PORT_NAME                "AMIMIRRORPREFS_PORT"
  183. #define SETS_FILE                      "ENV:amimirror.sets"
  184. #define PREFS_TOOLTYPES                "PREFS"
  185. #define PREFS_DEFAULT_PATH             "Sys:Prefs/AmiMirrorPrefs"
  186.  
  187. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  188. ///
  189. // Named numeric constants:
  190.  
  191. // work modes
  192. enum
  193. {
  194.   FUNCTION_SPARE,
  195.   FUNCTION_BACKUP,
  196.   FUNCTION_ANTIDEL
  197. };
  198.  
  199. // pattern modes
  200. enum
  201. {
  202.   PAT_MODE_NAME,
  203.   PAT_MODE_DIR,
  204.   PAT_MODE_PATH
  205. };
  206.  
  207. // storage modes
  208. enum
  209. {
  210.   STO_MODE_FILE,
  211.   STO_MODE_DIR
  212. };
  213.  
  214. // storage methods
  215. enum
  216. {
  217.   STO_METHOD_REPLACE,
  218.   STO_METHOD_SUFFIX
  219. };
  220.  
  221. // return values from some functions
  222. enum
  223. {
  224.   FUNK_CANCEL,
  225.   FUNK_YES,
  226.   FUNK_NO
  227. };
  228.  
  229. // catalog's messages
  230. enum
  231. {
  232.   PROG_VERSION,
  233.   PROG_COPYRIGHT,
  234.   CATALOG_NAME,
  235.   BUILTIN_LANGUAGE,
  236.   PROG_DESC,
  237.   REQ_TITLE_ERROR,
  238.   OUT_MEM,
  239.   LIBRARY_PROBLEM,
  240.   DOS_ERROR_STR,
  241.   CANT_LOCK,
  242.   CANT_CREATE,
  243.   CANT_OPEN_SETS,
  244.   CANT_READ_SETS,
  245.   NOT_SETS_FILE,
  246.   CANT_PARSE,
  247.   CANT_MSGPORT,
  248.   CANT_OPEN,
  249.   CANT_EXAM,
  250.   CANT_EXAMXPK,
  251.   CANT_READ,
  252.   CANT_DELETE,
  253.   CANT_RENAME,
  254.   CANT_WRITE,
  255.   CANT_PACK,
  256.   CANT_UNPACK,
  257.   QUIT_BUT,
  258.   CANCEL_BUT,
  259.   OK_BUT,
  260.  
  261.   FINISH,
  262. };
  263.  
  264. ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
  265. ///
  266. // Global data:
  267.  
  268. // catalog's strings
  269. STATIC STRPTR messages[] =
  270. {
  271.   "$VER: AmiMirror 2.0 (19.05.99)",
  272.   "AmiMirror © 1998-99 Black Square Software",
  273.   "amimirror.catalog",
  274.   "english",
  275.   "Spare/backup/antidelete copies.",
  276.   "AmiMirror error",
  277.   "Not enough memory",
  278.   "Can not open %s version %ld+",
  279.   "\nDOS Error",
  280.   "Cannot lock\n%s%s",
  281.   "Cannot create\n%s%s",
  282.   "Cannot open settings file\n%s%s",
  283.   "Cannot read settings file\n%s%s",
  284.   "Wrong settings file\n%s",
  285.   "Cannot prepare pattern\n%s%s",
  286.   "Cannot create message port",
  287.   "Cannot open file\n%s%s",
  288.   "Cannot examine file\n%s%s",
  289.   "Cannot examine file\n%s\nXPK Error: %s",
  290.   "Cannot read file\n%s%s",
  291.   "Cannot delete file\n%s%s",
  292.   "Cannot rename file\n%s%s",
  293.   "Cannot write file\n%s%s",
  294.   "Cannot pack\nXPK Error: %s",
  295.   "Cannot unpack file\n%s\nXPK Error: %s",
  296.   "Quit",
  297.   "Cancel",
  298.   "Ok"
  299. };
  300.  
  301. // patch functions
  302. extern LONG __far LVOClose;
  303. extern LONG __far LVOOpen;
  304. extern LONG __far LVODeleteFile;
  305. STATIC LONG __asm (*OldClose)(register __d1 BPTR);
  306. STATIC BPTR __asm (*OldOpen)(register __d1 STRPTR, register __d2 LONG);
  307. STATIC BOOL __asm (*OldDeleteFile)(register __d1 STRPTR);
  308.  
  309. // program data and buffers
  310. STATIC STRPTR *ttypes;
  311. STATIC struct  List PatList;
  312. STATIC struct  SignalSemaphore Sema;
  313. STATIC BOOL    patch = FALSE;
  314.  
  315. // commodity data
  316. STATIC CxObj *broker;
  317. STATIC struct MsgPort *broker_mp;
  318. STATIC ULONG  cxsigflag = 0L;
  319. STATIC struct NewBroker newbroker =
  320.   {
  321.     NB_VERSION,
  322.     "AmiMirror",
  323.     "AmiMirror",
  324.     NULL,
  325.     NBU_UNIQUE | NBU_NOTIFY,
  326.     COF_SHOW_HIDE,
  327.     0,
  328.     NULL,
  329.     0
  330.   };
  331.  
  332. // compiler data
  333. IMPORT LONG  __stack        = 8192L;
  334. IMPORT LONG  __STKNEED      = 2048L;
  335. IMPORT UBYTE __stdiowin[]   = "CON:10/10/200/80/AmiMirror";
  336.